package webServiceClient.academico;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class FrmMenus extends Activity {
	private Button btnCadAluno;
	private Button btnCadProfessor;
	private Button btnCadCurso;
	private Button btnCadDisciplina;
	private Button btnCadTurma;
	private Button btnFechar;
	private Button btnAtividade;
	private Button btnAtribuica;
	
	private void carregaBtn() {
		btnCadAluno = (Button) findViewById(R.FrmMenus.btnCadAluno);
		btnAtividade = (Button) findViewById(R.FrmMenus.btnAtividade);
		btnCadProfessor = (Button) findViewById(R.FrmMenus.btnCadProfessor);
		btnCadCurso = (Button) findViewById(R.FrmMenus.btnCadCurso);
		btnCadDisciplina = (Button) findViewById(R.FrmMenus.btnCadDisciplina);
		btnCadTurma = (Button) findViewById(R.FrmMenus.btnCadTurma);
		btnFechar = (Button) findViewById(R.FrmMenus.btnFechar);
		btnAtribuica = (Button) findViewById(R.FrmMenus.btnAtribuicao);
		btnAtribuica.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(FrmMenus.this, FrmAtribuicao.class);
				startActivity(i);
			}
		});
		btnAtividade.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(FrmMenus.this, FrmAtividade.class);
				startActivity(i);
			}
		});
		btnCadTurma.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(FrmMenus.this, FrmCadTurma.class);
				startActivity(i);
			}
		});
		btnCadDisciplina.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(FrmMenus.this, FrmCadDisciplina.class);
				startActivity(i);
			}
		});
		btnCadCurso.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(FrmMenus.this, FrmCurso.class);
				startActivity(i);
			}
		});
		btnCadAluno.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(FrmMenus.this, FrmCadAluno.class);
				startActivity(i);
			}
		});
		btnCadProfessor.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(FrmMenus.this, FrmCadProfessor.class);
				startActivity(i);
			}
		});
		btnFechar.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				try {
					WebServiceClient ws = new WebServiceClient();
					if (ws.logoffProfessor("logoffProfessor",
							Definicoes.getRaAdm(), Definicoes.getSenhaAdm())
							.equals("true")) {
						Toast t = Toast
								.makeText(
										FrmMenus.this,
										"Finalizando...",
										Toast.LENGTH_SHORT);
						t.show();
						finish();
					}
				} catch (Exception e) {
					Toast t = Toast
							.makeText(
									FrmMenus.this,
									"Erro ao finalizar, tente novemente em alguns segundos",
									Toast.LENGTH_LONG);
					t.show();
				}
			}
		});
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.frm_menus);
		carregaBtn();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.frm_menus, menu);
		return true;
	}

}
